package com.company.project.service.impl;

import com.company.project.dao.PeriodicalsCategoryMapper;
import com.company.project.model.PeriodicalsCategory;
import com.company.project.service.PeriodicalsCategoryService;
import com.company.project.core.AbstractService;
import com.company.project.util.PageUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.*;


/**
 * Created by CodeGenerator on 2018/10/10.
 */
@Service
@Transactional
public class PeriodicalsCategoryServiceImpl extends AbstractService<PeriodicalsCategory> implements PeriodicalsCategoryService {
    @Resource
    private PeriodicalsCategoryMapper periodicalsCategoryMapper;


    @Override
    public List<PeriodicalsCategory> getPeriodicalsCategoryByParent(Integer parent) {
        return periodicalsCategoryMapper.selectPeriodicalsCategoryByParent(parent);
    }

    /**
     * 后台查询期刊专业
     * @return
     */
    @Override
    public  PageUtil<Map<Object,Object>> adminSelectPc(Integer index) {
        PageUtil<Map<Object,Object>> pageUtil = new PageUtil();
        pageUtil.setPageSize(15);
        pageUtil.setCpage(index);
        pageUtil.setTotalRow(this.PCNum());
        pageUtil.setLists(periodicalsCategoryMapper.adminSelectPc(pageUtil));
        List<Map<Object, Object>> maps = periodicalsCategoryMapper.adminSelectPc(pageUtil);
        return pageUtil;
    }

    @Override
    public Integer PCNum() {
        return periodicalsCategoryMapper.PCNum();
    }

    /**
     * 后台修改期刊专业
     * @param periodicalsCategory
     * @return
     */
    @Override
    public Boolean adminUpPc(PeriodicalsCategory periodicalsCategory) {
        return periodicalsCategoryMapper.adminUpPc(periodicalsCategory);
    }

    /**
     * 查询所有一级期刊专业
     * @return
     */
    @Override
    public List<PeriodicalsCategory> stair() {
        return periodicalsCategoryMapper.stair();
    }

    /**
     * 后台添加期刊专业
     * @param periodicalsCategory
     * @return
     */
    @Override
    public Boolean adminAddPc(PeriodicalsCategory periodicalsCategory) {
        return periodicalsCategoryMapper.adminAddPc(periodicalsCategory);
    }

    /**
     * 后台删除期刊专业
     * @param periodicalsCategory
     * @return
     */
    @Override
    public Boolean adminDelPc(PeriodicalsCategory periodicalsCategory) {
            Boolean aBoolean = periodicalsCategoryMapper.adminDelPc(periodicalsCategory);
            if (aBoolean.equals(true)){
                return true;
            }
            return false;
    }


    @Override
    public List<PeriodicalsCategory> adminGetPcP() {
        return periodicalsCategoryMapper.adminSelectPcP();
    }
}
